import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:flutter_base/config/app_color.dart';
import 'package:flutter_base/generated/assets.dart';
import 'package:flutter_base/widgets/image/auto_image.dart';

/// 性别选择器组件
/// 用于底部弹窗中的性别选择
class GenderSelectorWidget extends StatelessWidget {
  /// 当前选中的性别 (默认：male)
  final String? selectedGender;
  
  /// 性别选择回调
  final Function(String gender)? onGenderSelected;

  const GenderSelectorWidget({
    Key? key,
    this.selectedGender,
    this.onGenderSelected,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
          child: GestureDetector(
            onTap: () {
              if (onGenderSelected != null) {
                onGenderSelected!('male');
              } else {
                Get.back(result: 'male');
              }
            },
            child: Container(
              height: 40.w,
              decoration: BoxDecoration(
                color: AppColor.colorF5F7FA,
                borderRadius: BorderRadius.circular(40.w),
                border: selectedGender == 'male' 
                    ? Border.all(color: AppColor.primary, width: 1.w)
                    : null,
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  AutoImage(
                    Assets.commonMale,
                    width: 24.w,
                    height: 24.w,
                    color: AppColor.color5097E8,
                  ),
                  SizedBox(width: 9.w),
                  Text(
                    'Male',
                    style: TextStyle(
                      color: AppColor.color0C0A09,
                      fontSize: 14.sp,
                      fontWeight: FontWeight.w500,
                      fontFamily: 'Outfit',
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
        SizedBox(width: 24.w),
        Expanded(
          child: GestureDetector(
            onTap: () {
              if (onGenderSelected != null) {
                onGenderSelected!('female');
              } else {
                Get.back(result: 'female');
              }
            },
            child: Container(
              height: 40.w,
              decoration: BoxDecoration(
                color: AppColor.colorF5F7FA,
                borderRadius: BorderRadius.circular(40.w),
                border: selectedGender == 'female' 
                    ? Border.all(color: AppColor.primary, width: 1.w)
                    : null,
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  AutoImage(
                    Assets.commonFemale,
                    width: 24.w,
                    height: 24.w,
                    color: AppColor.colorF453BF,
                  ),
                  SizedBox(width: 9.w),
                  Text(
                    'Female',
                    style: TextStyle(
                      color: AppColor.color0C0A09,
                      fontSize: 14.sp,
                      fontWeight: FontWeight.w500,
                      fontFamily: 'Outfit',
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ],
    );
  }
} 